package controler.userCommands;
import controler.A_State;
import controler.A_UserCommand;
import view.PropertyPanel;

/**
 * @author Damien Mabin
 */

class ChangeElementProperty<T> extends A_UserCommand
{
	private var m_Class 			: Class<T>;
	private var m_Elt 				: T;
	private var m_PropertyType 		: E_PropertyType;
	private var m_PropertyValue 	: String;
	private var m_OldPropertyValue 	: String;
	
	public function new(_NextState:A_State, _Class:Class<T>, _Elt:T, _PropertyType:E_PropertyType, _PropertyValue:String) 
	{
		super(_NextState);
		m_CanBeUndo = true;
		m_Stackable = false;
		
		m_Class = _Class;
		m_Elt = _Elt;
		m_PropertyType = _PropertyType;
		m_PropertyValue = _PropertyValue;
		m_OldPropertyValue = A_UserCommand.s_Model.CTRL_GetElementProperty(m_Class, m_Elt, m_PropertyType);
	}
	
	override public function DoCommand():Void 
	{
		super.DoCommand();
		A_UserCommand.s_Model.CTRL_SetElementProperty(m_Class, m_Elt, m_PropertyType, m_PropertyValue);
	}
	
	override public function UndoCommand():Void 
	{
		A_UserCommand.s_Model.CTRL_SetElementProperty(m_Class, m_Elt, m_PropertyType, m_PropertyValue);
		super.UndoCommand();
	}
	
}